// 用户类型
export interface User {
  _id: string;
  name: string;
  phone: string;
  role: 'user' | 'maintainer' | 'admin';
  email?: string;
  address?: string;
  avatar?: string;
  isActive: boolean;
  createdAt: string;
  updatedAt: string;
  lastLoginAt?: string;
  
  // 维修员特有字段
  skills?: string[];
  experience?: number;
  rating?: number;
  completedOrders?: number;
}

// 工单类型
export interface Order {
  _id: string;
  orderNumber: string;
  title: string;
  description: string;
  type: 'repair' | 'maintenance' | 'installation' | 'inspection';
  status: 'pending' | 'assigned' | 'processing' | 'completed' | 'cancelled';
  urgency: 'low' | 'medium' | 'high' | 'urgent';
  
  // 用户信息
  user: {
    id: string;
    name: string;
    phone: string;
    email?: string;
    address: string;
  };
  
  // 维修员信息
  maintainer?: {
    id: string;
    name: string;
    phone: string;
    skills: string[];
  };
  
  // 服务相关
  serviceFee?: number;
  estimatedDuration?: number;
  actualDuration?: number;
  
  // 评价相关
  rating?: number;
  feedback?: string;
  
  // 附件
  attachments: string[];
  
  // 时间戳
  createdAt: string;
  updatedAt: string;
  assignedAt?: string;
  startedAt?: string;
  completedAt?: string;
}

// 统计数据类型
export interface Statistics {
  totalOrders: number;
  pendingOrders: number;
  processingOrders: number;
  completedOrders: number;
  cancelledOrders: number;
  totalUsers: number;
  totalMaintainers: number;
  activeMaintainers: number;
  averageRating: number;
  completionRate: number;
  
  // 状态分布
  statusDistribution: {
    waiting: number;
    processing: number;
    completed: number;
    cancelled: number;
    evaluated: number;
  };
  
  // 月度趋势
  monthlyOrders: {
    _id: string;
    count: number;
  }[];
  
  // 顶级维修员
  topMaintainers: {
    _id: string;
    name: string;
    rating: number;
    completedOrders: number;
  }[];
}

// API响应类型
export interface ApiResponse<T = any> {
  success: boolean;
  message: string;
  code: number;
  data: T;
}

// 分页类型
export interface PaginatedResponse<T> {
  items: T[];
  pagination: {
    page: number;
    limit: number;
    total: number;
    totalPages: number;
    hasNext: boolean;
    hasPrev: boolean;
  };
}

// 查询参数类型
export interface QueryParams {
  page?: number;
  limit?: number;
  search?: string;
  status?: string;
  type?: string;
  urgency?: string;
  assignedTo?: string;
  dateFrom?: string;
  dateTo?: string;
  sortBy?: string;
  sortOrder?: 'asc' | 'desc';
}

// 登录请求类型
export interface LoginRequest {
  phone: string;
  password: string;
}

// 登录响应类型
export interface LoginResponse {
  user: User;
  token: string;
}

// 更新工单状态请求类型
export interface UpdateOrderStatusRequest {
  status: Order['status'];
  notes?: string;
  serviceFee?: number;
  estimatedDuration?: number;
}

// 分配工单请求类型
export interface AssignOrderRequest {
  maintainerId: string;
  notes?: string;
  estimatedDuration?: number;
}

// 评价工单请求类型
export interface EvaluateOrderRequest {
  rating: number;
  feedback?: string;
}

// 路由参数类型
export interface RouteParams {
  orderId?: string;
  userId?: string;
}